package com.example.diet_sport.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.diet_sport.entity.user;
import com.example.diet_sport.entity.userfood;
import com.example.diet_sport.mapper.userMapper;
import com.example.diet_sport.mapper.userfoodMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 伽蓝尘
 * @create 2023-06-06 14:44
 */
@RequestMapping("/userfood")
@RestController
@CrossOrigin
public class userfoodController {

    @Autowired
    private userfoodMapper userfoodMapper;



    @PostMapping("/add")
    @ResponseBody
    public int add(userfood userfood) {
        return userfoodMapper.insert(userfood);
    }

    @ResponseBody
    @GetMapping("/userfoodList")
    public List<userfood> getDayUserFoodList(String day,int uid){
        QueryWrapper<userfood> wrapper = new QueryWrapper<>();
        wrapper.eq("uid",uid);
        wrapper.eq("day",day);
        return userfoodMapper.selectList(wrapper);
    }





}
